package com.rybbaby.tss.front.tssMemberPackageHistory.service.imp;

import com.rybbaby.tss.core.web.service.imp.BaseServiceImp;
import com.rybbaby.tss.front.tssMemberCheckAttendanceHistory.entity.TssMemberCheckAttendanceHistory;
import com.rybbaby.tss.front.tssMemberPackage.entity.TssMemberPackage;
import com.rybbaby.tss.front.tssMemberPackageHistory.dao.ITssMemberPackageHistoryDao;
import com.rybbaby.tss.front.tssMemberPackageHistory.entity.TssMemberPackageHistory;
import com.rybbaby.tss.front.tssMemberPackageHistory.service.ITssMemberPackageHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;


/**
 * @author 雷春琼
 * @description 会员课时包数据库操作服务实现
 * @createDate 2017-08-10 上午12:04:35
 */
@Service
@Transactional
public class TssMemberPackageHistoryServiceImp extends BaseServiceImp<TssMemberPackageHistory> implements ITssMemberPackageHistoryService {


    @Autowired
    private ITssMemberPackageHistoryDao tssMemberPackageHistoryDao;


    @Override
    public boolean batchSave(List<TssMemberPackage> entitys) throws Exception {
        ArrayList<TssMemberPackageHistory> tssMemberPackageHistories = new ArrayList<TssMemberPackageHistory>();
        String id = "";
        for (int j = 0; j < entitys.size(); j++) {
            TssMemberPackageHistory tssMemberPackageHistory = new TssMemberPackageHistory();
            id = UUID.randomUUID().toString().replace("-", "");
            tssMemberPackageHistory.setId(id);
            tssMemberPackageHistory.setMemberPackageId(entitys.get(j).getId());
            tssMemberPackageHistory.setMemberId(entitys.get(j).getMemberId());
            tssMemberPackageHistory.setContractNumber(entitys.get(j).getContractNumber());
            tssMemberPackageHistory.setPackageId(entitys.get(j).getPackageId());
            tssMemberPackageHistory.setApplyStatus(entitys.get(j).getApplyStatus());
            tssMemberPackageHistory.setFreezeClassHour(entitys.get(j).getFreezeClassHour());
            tssMemberPackageHistory.setDueTime(entitys.get(j).getDueTime());
            tssMemberPackageHistory.setGifts(entitys.get(j).getGifts());
            tssMemberPackageHistory.setTeacherId(entitys.get(j).getTeacherId());

            tssMemberPackageHistory.setNowUnitPrice(entitys.get(j).getNowUnitPrice());
            tssMemberPackageHistory.setDiscountedPrice(entitys.get(j).getDiscountedPrice());
            tssMemberPackageHistory.setSumPrice(entitys.get(j).getSumPrice());
            tssMemberPackageHistory.setGiftAttendanceDay(entitys.get(j).getGiftAttendanceDay());
            tssMemberPackageHistory.setIsComplimentaryMeals(entitys.get(j).getIsComplimentaryMeals());
            tssMemberPackageHistory.setAttendanceDay(entitys.get(j).getAttendanceDay());
            tssMemberPackageHistory.setAttendedDay(entitys.get(j).getAttendedDay());
            tssMemberPackageHistory.setAbsentDay(entitys.get(j).getAbsentDay());
            tssMemberPackageHistory.setSurplusAttendanceDay(entitys.get(j).getSurplusAttendanceDay());
            tssMemberPackageHistory.setSurplusFormalAttendanceDay(entitys.get(j).getSurplusFormalAttendanceDay());

            tssMemberPackageHistory.setSurplusPresentAttendanceDay(entitys.get(j).getSurplusPresentAttendanceDay());
            tssMemberPackageHistory.setSelectedAttendanceDay(entitys.get(j).getSelectedAttendanceDay());
            tssMemberPackageHistory.setConsumptionAttendanceDay(entitys.get(j).getConsumptionAttendanceDay());
            tssMemberPackageHistory.setPositiveConsumptionAttendanceDay(entitys.get(j).getPositiveConsumptionAttendanceDay());
            tssMemberPackageHistory.setGiftConsumptionAttendanceDay(entitys.get(j).getGiftConsumptionAttendanceDay());
            tssMemberPackageHistory.setUnusedAttendanceDay(entitys.get(j).getUnusedAttendanceDay());
            tssMemberPackageHistory.setPositiveUnusedAttendanceDay(entitys.get(j).getPositiveUnusedAttendanceDay());
            tssMemberPackageHistory.setGiftUnusedAttendanceDay(entitys.get(j).getGiftUnusedAttendanceDay());
            tssMemberPackageHistory.setNature(entitys.get(j).getNature());
            tssMemberPackageHistory.setIsShare(entitys.get(j).getIsShare());

            tssMemberPackageHistory.setEmpAdminUserId(entitys.get(j).getEmpAdminUserId());
            tssMemberPackageHistory.setPresentClassHour(entitys.get(j).getPresentClassHour());
            tssMemberPackageHistory.setUsableTotalClassHour(entitys.get(j).getUsableTotalClassHour());
            tssMemberPackageHistory.setSurplusClassHour(entitys.get(j).getSurplusClassHour());
            tssMemberPackageHistory.setSurplusFormalClassHour(entitys.get(j).getSurplusFormalClassHour());
            tssMemberPackageHistory.setSurplusPresentClassHour(entitys.get(j).getSurplusPresentClassHour());
            tssMemberPackageHistory.setSelectedClassHour(entitys.get(j).getSelectedClassHour());
            tssMemberPackageHistory.setConsumptionClassHour(entitys.get(j).getConsumptionClassHour());
            tssMemberPackageHistory.setPositiveConsumptionClassHour(entitys.get(j).getPositiveConsumptionClassHour());
            tssMemberPackageHistory.setGiftConsumptionClassHour(entitys.get(j).getGiftConsumptionClassHour());

            tssMemberPackageHistory.setUnusedClassHour(entitys.get(j).getUnusedClassHour());
            tssMemberPackageHistory.setPositiveUnusedClassHour(entitys.get(j).getPositiveUnusedClassHour());
            tssMemberPackageHistory.setGiftUnusedClassHour(entitys.get(j).getGiftUnusedClassHour());
            tssMemberPackageHistory.setRemediationClassHour(entitys.get(j).getRemediationClassHour());
            tssMemberPackageHistory.setUsableTotal(entitys.get(j).getUsableTotal());
            tssMemberPackageHistory.setSurplusValidDate(entitys.get(j).getSurplusValidDate());
            tssMemberPackageHistory.setAdminUserId(entitys.get(j).getAdminUserId());
            tssMemberPackageHistory.setRemark(entitys.get(j).getRemark());
            tssMemberPackageHistory.setPackageStatus(entitys.get(j).getPackageStatus());
            tssMemberPackageHistory.setCreateTime(entitys.get(j).getCreateTime());

            tssMemberPackageHistory.setVersion(entitys.get(j).getVersion());
            tssMemberPackageHistory.setType(entitys.get(j).getType());
            tssMemberPackageHistory.setUpdateTime(entitys.get(j).getUpdateTime());
            tssMemberPackageHistory.setIsAddSubtract(entitys.get(j).getIsAddSubtract());
            tssMemberPackageHistory.setIsAttendClass(entitys.get(j).getIsAttendClass());

            tssMemberPackageHistories.add(j,tssMemberPackageHistory);
        }
        return tssMemberPackageHistoryDao.batchSave(tssMemberPackageHistories);
    }
}
